<?php
namespace pqphp\base;

use pqphp\db\Sql;

class Model extends Sql
{
    protected $model;
	protected $config=[];//读取config配置文件

    public function __construct()
    {
        // 获取数据库表名
        if (!$this->table) {

            // 获取模型类名称
            $this->model = get_class($this);

            // 删除类名最后的 Model 字符
            $this->model = substr($this->model, 0, -5);

            // 数据库表名与类名一致
            $this->table = strtolower($this->model);
        }
		$this->initconfig();
    }

	public function settablename($tablename)
	{
		$this->table = $tablename;
	}

	/*日志记录处理
	 */
	public function paylogs($msg)
	{
		$data['desc']=$msg;
		$data['createtime']=date('Y-m-d H:i:s', time());
		$data['pid']=isset($_SESSION['pid'])?$_SESSION['pid']: '';
		$data['ip']=isset($_SESSION['userip'])?$_SESSION['userip']: '';
		$this->insertData($data,'paylogs');
	}

	public function initconfig()
	{
		$this->config = include("../pays/config/config.php");
	}
}